package com.dragon.loan.service;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import com.dragon.loan.entity.AcCaseStatusTrace;
import com.dragon.loan.repository.AcCaseStatusTraceRepository;

@Service("acCaseStatusTrace")
public class AcCaseStatusTraceImpl implements AcCaseStatusTraceService{

	@Autowired
	private AcCaseStatusTraceRepository acCaseStatusTraceRepository;
	
	
	public void saveCaseStatusTrace(String loanId, String description, Date createTime, String status) {
		String[] desc = null;
		if (StringUtils.hasText(description)) {
			desc = description.split(",");
		}
		if (null == desc || desc.length < 1) {
			return;
		}
		if (null == createTime) {
			createTime = new Date();
		}
		for (String str : desc) {
			AcCaseStatusTrace acCaseStatusTrace = new AcCaseStatusTrace();
			acCaseStatusTrace.setLoanId(loanId);
			acCaseStatusTrace.setDescription(str);
			acCaseStatusTrace.setCreateTime(createTime);
			acCaseStatusTrace.setStatus(status);
			acCaseStatusTraceRepository.insert(acCaseStatusTrace);
		}
	}
}
